'''###########################################################################################################################
### File: level_file_menu_gui.py
### Name: Patrick Delaney, Andrew Oberlin
### Class: CSE 487
### Instructor: Dr.Zmuda
### Assignment: Final Project
### Description: Class for handling the level generation
################ 
'''
from menu_button import MenuButton
from panda3d.core import Vec2, Point3, Vec3, Vec4

class LevelFileMenuGUI:
	'''
	### Name: __init__ (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: 
	'''
	def __init__(self, parent, projectName, levelGen):
		self.parent = parent
		self.projectName = projectName
		self.levelGen = levelGen
		self.models = dict()
		self.__loadModels()

	'''
	### Name: __loadModels
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Loads the GUI objects
	'''
	def __loadModels(self):
		self.models['background'] = self.parent.loader.loadModelCopy("models/plane")
		self.backgroundTexture = self.parent.loader.loadTexture("models/gui/game_maker/menu_background.jpg")
		self.models['background'].setTexture(self.backgroundTexture)
		self.models['background'].setTransparency(1)
		self.models['background'].setScale(2.67, 1, 0.20)
		self.models['background'].setZ(1)
		self.models['background'].reparentTo(self.parent.base.aspect2d)
		
		self.models['save'] = MenuButton(
			self.parent, 'save_level_button', 'models/gui/game_maker/dialog_button', 
			self.save, Vec3(-1.1, 0, 0.95), isMovie = False, text="Save", 
			textPos=Vec3(-0.115, 0, -0.025), scale=Vec3(0.275,1,0.1)
		)
		
		self.models['exit'] = MenuButton(
			self.parent, 'exit_button', 'models/gui/game_maker/dialog_button', 
			self.exit, Vec3(1.10, 0, 0.95), isMovie = False, text="Exit", 
			textPos=Vec3(-0.10, 0, -0.025), scale=Vec3(0.25,1,0.1)
		)
		
		
	'''
	### Name: hide
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: hides this GUI
	'''
	def hide(self):
		for key in self.models.keys():
			self.models[key].hide()
			
	'''
	### Name: show
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: show this GUI
	'''
	def show(self):
		for key in self.models.keys():
			self.models[key].show()
			
			
	'''
		Exits the level editor
	'''
	def exit(self):
		if (not self.levelGen.keys["toggleModes"]):
			self.levelGen.cleanupLevel()
		#else statement telling you to hit the space bar
		
	'''
		Saves the current level
	'''
	def save(self):
		if (not self.levelGen.keys["toggleModes"]):
			self.levelGen.saveLevel()
		
		